class BuycardPanel extends BasePanel {

    private lab_description: eui.Label;
    private group: eui.Group;
    private btn_kefu: ButtonEx;
    private btn_record: eui.Button;

    public constructor() {
        super();
        this.skinName = "BuycardPanelSkin";
    }

    childrenCreated() {
        super.childrenCreated();

        this.lab_description.text = "" + GameConfig.wx_contact;

        this.updateConfig();

        this.btn_kefu.addEventListener(egret.TouchEvent.TOUCH_TAP, this.clickHandler, this);
        this.btn_record.addEventListener(egret.TouchEvent.TOUCH_TAP, this.clickHandler, this);

    }

    private clickHandler(e: egret.TouchEvent) {
        switch (e.currentTarget) {
            case this.btn_kefu:
                game.askPanel.showMsg(function (b: boolean) {
                    if (b) location.href = GameConfig.kefu_href;
                }, '确定要离开当前游戏页面，前往客服中心吗？');
                break;
            case this.btn_record:
                gameManager.open('BuycardRecordPanel');
                break;
        }
    }

    private updateConfig() {
        if (!GameConfig.switch_kefu) {
            if (this.group.contains(this.btn_kefu)) this.group.removeChild(this.btn_kefu);
        }
    }
}